<?php

class MydbForeignKeys
{
    /**
    * make changes to the database.
    *
    * @return void
    */
    public function up()
    {
        Schema::table('bo_mon', function($table)
        {
            // foreign keys for table 'bo_mon'

            $table->foreign('id_khoa')->references('id')->on('khoa');
        });

        Schema::table('can_bo', function($table)
        {
            // foreign keys for table 'can_bo'

            $table->foreign('id_nguoi_dung')->references('id')->on('nguoi_dung');
            $table->foreign('id_bo_mon')->references('id')->on('bo_mon');
        });

        Schema::table('chi_tiet_can_bo_huong_dan', function($table)
        {
            // foreign keys for table 'chi_tiet_can_bo_huong_dan'

            $table->foreign('id_can_bo')->references('id')->on('can_bo');
            $table->foreign('id_de_tai')->references('id')->on('de_tai_luan_van');
        });

        Schema::table('chi_tiet_hoi_dong', function($table)
        {
            // foreign keys for table 'chi_tiet_hoi_dong'

            $table->foreign('id_can_bo')->references('id')->on('can_bo');
            $table->foreign('id_hoi_dong')->references('id')->on('hoi_dong_xet_duyet');
        });

        Schema::table('chi_tiet_ke_hoach', function($table)
        {
            // foreign keys for table 'chi_tiet_ke_hoach'

            $table->foreign('id_cv')->references('id')->on('cong_viec');
            $table->foreign('id_dg')->references('id')->on('muc_do_hoan_thanh');
            $table->foreign('id_ke_hoach')->references('id')->on('ke_hoach_huong_dan');
        });

        Schema::table('chi_tiet_nhom_quyen_han', function($table)
        {
            // foreign keys for table 'chi_tiet_nhom_quyen_han'

            $table->foreign('id_tac_vu_he_thong')->references('id')->on('tac_vu_he_thong');
            $table->foreign('id_nhom_quyen')->references('id')->on('nhom_quyen_han');
        });

        Schema::table('danh_gia_sv', function($table)
        {
            // foreign keys for table 'danh_gia_sv'

            $table->foreign('id_chi_tiet_hd')->references('id')->on('chi_tiet_hoi_dong');
            $table->foreign('id_sinh_vien')->references('id')->on('sinh_vien');
        });

        Schema::table('de_tai_luan_van', function($table)
        {
            // foreign keys for table 'de_tai_luan_van'

            $table->foreign('id_hoc_ki_nien_khoa')->references('id')->on('hoc_ky_nien_khoa');
            $table->foreign('id_bo_mon')->references('id')->on('bo_mon');
        });
        
        Schema::table('hoc_ky_nien_khoa', function($table)
        {
            // foreign keys for table 'hoc_ky_nien_khoa'

            $table->foreign('id_thoi_gian')->references('id')->on('quy_dinh_thoi_gian');
        });
        Schema::table('hoi_dong_xet_duyet', function($table)
        {
            // foreign keys for table 'hoi_dong_xet_duyet'

            $table->foreign('id_de_tai')->references('id')->on('de_tai_luan_van');
        });

        Schema::table('ke_hoach_huong_dan', function($table)
        {
            // foreign keys for table 'ke_hoach_huong_dan'

            $table->foreign('id_de_tai')->references('id')->on('de_tai_luan_van');
        });

        Schema::table('lich_su_hoat_dong', function($table)
        {
            // foreign keys for table 'lich_su_hoat_dong'

            $table->foreign('id_nguoi_dung')->references('id')->on('nguoi_dung');
            $table->foreign('id_tac_vu_he_thong')->references('id')->on('tac_vu_he_thong');
        });

        Schema::table('lop', function($table)
        {
            // foreign keys for table 'lop'

            $table->foreign('id_bo_mon')->references('id')->on('bo_mon');
        });

        Schema::table('nhom_dang_ki', function($table)
        {
            // foreign keys for table 'nhom_dang_ki'

            $table->foreign('id_de_tai')->references('id')->on('de_tai_luan_van');
            $table->foreign('id_sinh_vien')->references('id')->on('sinh_vien');
        });

        Schema::table('sinh_vien', function($table)
        {
            // foreign keys for table 'sinh_vien'

            $table->foreign('id_nguoi_dung')->references('id')->on('nguoi_dung');
            $table->foreign('id_lop')->references('id')->on('lop');
        });

        Schema::table('chi_tiet_tg_tv', function($table)
        {
            // foreign keys for table 'chi_tiet_tg_tv'

            $table->foreign('id_thoi_gian')->references('id')->on('quy_dinh_thoi_gian');
            $table->foreign('id_tac_vu')->references('id')->on('tac_vu_he_thong');
        });

        Schema::table('thong_bao', function($table)
        {
            // foreign keys for table 'thong_bao'

            $table->foreign('id_bo_mon')->references('id')->on('bo_mon');
            $table->foreign('id_nguoi_dung')->references('id')->on('nguoi_dung');
        });

        Schema::table('truong_bo_mon', function($table)
        {
            // foreign keys for table 'truong_bo_mon'

            $table->foreign('id_bo_mon')->references('id')->on('bo_mon');
            $table->foreign('id_can_bo')->references('id')->on('can_bo');
        });

    }

    /**
    * revert the changes to the database.
    *
    * @return void
    */
    public function down()
    {
        Schema::table('bo_mon', function($table)
        {
            // drop foreign keys for table 'bo_mon'

            $table->dropforeign('bo_mon_id_khoa_foreign');
        });

        Schema::table('can_bo', function($table)
        {
            // drop foreign keys for table 'can_bo'

            $table->dropforeign('can_bo_id_nguoi_dung_foreign');
            $table->dropforeign('can_bo_id_bo_mon_foreign');
        });

        Schema::table('chi_tiet_can_bo_huong_dan', function($table)
        {
            // drop foreign keys for table 'chi_tiet_can_bo_huong_dan'

            $table->dropforeign('chi_tiet_can_bo_huong_dan_id_can_bo_foreign');
            $table->dropforeign('chi_tiet_can_bo_huong_dan_id_de_tai_foreign');
        });

        Schema::table('chi_tiet_hoi_dong', function($table)
        {
            // drop foreign keys for table 'chi_tiet_hoi_dong'

            $table->dropforeign('chi_tiet_hoi_dong_id_can_bo_foreign');
            $table->dropforeign('chi_tiet_hoi_dong_id_hoi_dong_foreign');
        });

        Schema::table('chi_tiet_ke_hoach', function($table)
        {
            // drop foreign keys for table 'chi_tiet_ke_hoach'

            $table->dropforeign('chi_tiet_ke_hoach_id_cv_foreign');
            $table->dropforeign('chi_tiet_ke_hoach_id_dg_foreign');
            $table->dropforeign('chi_tiet_ke_hoach_id_ke_hoach_foreign');
        });

        Schema::table('chi_tiet_nhom_quyen_han', function($table)
        {
            // drop foreign keys for table 'chi_tiet_nhom_quyen_han'

            $table->dropforeign('chi_tiet_nhom_quyen_han_id_tac_vu_he_thong_foreign');
            $table->dropforeign('chi_tiet_nhom_quyen_han_id_nhom_quyen_foreign');
        });

        Schema::table('danh_gia_sv', function($table)
        {
            // drop foreign keys for table 'danh_gia_sv'

            $table->dropforeign('danh_gia_sv_id_chi_tiet_hd_foreign');
            $table->dropforeign('danh_gia_sv_id_sinh_vien_foreign');
        });

        Schema::table('de_tai_luan_van', function($table)
        {
            // drop foreign keys for table 'de_tai_luan_van'

            $table->dropforeign('de_tai_luan_van_id_hoc_ki_nien_khoa_foreign');
            $table->dropforeign('de_tai_luan_van_id_bo_mon_foreign');
        });
        
        Schema::table('hoc_ky_nien_khoa', function($table)
        {
            // drop foreign keys for table 'hoc_ky_nien_khoa'

            $table->dropforeign('hoc_ky_nien_khoa_id_thoi_gian_foreign');
        });
        Schema::table('hoi_dong_xet_duyet', function($table)
        {
            // drop foreign keys for table 'hoi_dong_xet_duyet'

            $table->dropforeign('hoi_dong_xet_duyet_id_de_tai_foreign');
        });

        Schema::table('ke_hoach_huong_dan', function($table)
        {
            // drop foreign keys for table 'ke_hoach_huong_dan'

            $table->dropforeign('ke_hoach_huong_dan_id_de_tai_foreign');
        });

        Schema::table('lich_su_hoat_dong', function($table)
        {
            // drop foreign keys for table 'lich_su_hoat_dong'

            $table->dropforeign('lich_su_hoat_dong_id_nguoi_dung_foreign');
            $table->dropforeign('lich_su_hoat_dong_id_tac_vu_he_thong_foreign');
        });

        Schema::table('lop', function($table)
        {
            // drop foreign keys for table 'lop'

            $table->dropforeign('lop_id_bo_mon_foreign');
        });

        Schema::table('nhom_dang_ki', function($table)
        {
            // drop foreign keys for table 'nhom_dang_ki'

            $table->dropforeign('nhom_dang_ki_id_de_tai_foreign');
            $table->dropforeign('nhom_dang_ki_id_sinh_vien_foreign');
        });

        Schema::table('sinh_vien', function($table)
        {
            // drop foreign keys for table 'sinh_vien'

            $table->dropforeign('sinh_vien_id_nguoi_dung_foreign');
            $table->dropforeign('sinh_vien_id_lop_foreign');
        });

        Schema::table('chi_tiet_tg_tv', function($table)
        {
            // drop foreign keys for table 'chi_tiet_tg_tv'

            $table->dropforeign('chi_tiet_tg_tv_id_thoi_gian_foreign');
            $table->dropforeign('chi_tiet_tg_tv_id_tac_vu_foreign');
        });

        Schema::table('thong_bao', function($table)
        {
            // drop foreign keys for table 'thong_bao'

            $table->dropforeign('thong_bao_id_bo_mon_foreign');
            $table->dropforeign('thong_bao_id_nguoi_dung_foreign');
        });

        Schema::table('truong_bo_mon', function($table)
        {
            // drop foreign keys for table 'truong_bo_mon'

            $table->dropforeign('truong_bo_mon_id_bo_mon_foreign');
            $table->dropforeign('truong_bo_mon_id_can_bo_foreign');
        });
    }
}